<?xml version="1.0" encoding="utf-8"?>
<html xmlns:str="http://exslt.org/strings"><head><title>duetopia - Documentation - OpenSearch</title><link rel="stylesheet" href="docs.css"/></head><body><div class="menu"><h3>Setup</h3><p><a href="installation.html">Installation</a><br/><a href="configuration.html">Configuration</a></p><h4>Customisation</h4><p><a href="custom_classes.html">Custom Classes</a></p><h3>Interfaces</h3><p><a href="api.html">Quick API Guide</a><br/><a href="opensearch.html">Opensearch Guide</a><br/><a href="opensearch_client.html">Opensearch Client</a></p></div><div id="header">
<h1>duetopia</h1>
</div><div id="content">
<h2>API</h2>

<div id="cmenu">
<ul>
<li><a href="#rdf">RDF import</a></li>
<li><a href="#trans">RDF Transformation</a></li>
<li><a href="#ows">OWS import</a></li>
<li><a href="#opensearch">OpenSearch query</a></li>
</ul>
</div>

<a name="rdf"/>
<h3>RDF Import</h3>
<p>Duetopia has a simple RDF/XML-based API with a REST-style interface. 
Use this to contribute records of datasets and to annotate existing records.</p>

<p>
To <em>import</em> records into the database, POST its description in RDF/XML to the following URL on your webserver.
<pre>
        <b>/duetopia/register/dataset/import/rdf</b>
</pre>
Here is a fairly full example of a record of a data set, a member of a series, that will be consumed at this URI. Note that the creation of a data set here will automatically invoke the creation of both the series and the contact agent.
<br/>
<a href="#pastrdf">skip XML</a>
<pre>
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;rdf:RDF
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        xmlns:dct="http://purl.org/dc/terms/"
        xmlns:dclite4g="http://dclite4g.xmlns.com/schema.rdf#"
        xmlns:foaf="http://xmlns.com/foaf/spec/"
        xmlns:ical="http://www.w3.org/2002/12/cal/ical#"&gt;

  &lt;dclite4g:Series rdf:about="http://www.example.com/series/example_series/"&gt;
    &lt;dc:title&gt;An Example Data Series&lt;/dc:title&gt;
    &lt;dc:abstract&gt;Description of example series&lt;/dc:abstract&gt;
    &lt;dc:subject&gt;example&lt;/dc:subject&gt;
    &lt;dc:contact rdf:resource="http://www.example.com/contact/" /&gt;
    &lt;dct:spatial&gt;POLYGON ((-18.125 30.25, -18.125 46.0, 36.25 46.0, 36.25 30.25, -18.125 30.25))&lt;/dct:spatial&gt;
    &lt;dclite4g:projection&gt;EPSG:4326&lt;/dclite4g:projection&gt;
  &lt;/dclite4g:Series&gt;

  &lt;dclite4g:DataSet rdf:about="http://www.example.com/series/example_series/example_data_set/"&gt;
    &lt;dclite4g:series rdf:resource="http://www.example.com/series/example_series/" /&gt;
    &lt;dc:identifier&gt;duetopia_example_dataset&lt;/dc:identifier&gt;
    &lt;dclite4g:fileFormat&gt;NetCDF&lt;/dclite4g:fileFormat&gt;
    &lt;ical:dtstart&gt;1970-01-01 00:00:00&lt;/ical:dtstart&gt;
    &lt;ical:dtend&gt;1970-01-01 23:59:59&lt;/ical:dtend&gt;
  &lt;/dclite4g:DataSet&gt;

  &lt;foaf:Person about="http://www.example.com/contact/"&gt;
    &lt;foaf:name&gt;Example Contact&lt;/foaf:name&gt;
    &lt;foaf:mbox&gt;contact@example.com&lt;/foaf:mbox&gt;
  &lt;/foaf:Person&gt;

&lt;/rdf:RDF&gt;
</pre>

The following snippet of python shows this request being sent:
<pre>
    <b>from urllib2 import Request, urlopen
    request = Request('http://example.com/duetopia/register/dataset/import/rdf", open('simple.rdf').read())
    request = urlopen(request)
    response = request.read()</b>
</pre>

<a name="pastrdf"/>
This import method is defined in the RDF package for all classes of objects in the database storage. Thus whenever you add a custom class to store a different set of fields in the database, you add an "import/rdf" method to it automatically.
<pre>
        /duetopia/register/[class]/import/rdf
</pre>
</p>
<h4>Annotating RDF</h4>
<p>Annotate a dataset with extra fields, by POSTing a section of RDF/XML to the following URL:
<pre>
        
        <b>/duetopia/register/dataset/annotate/rdf</b>
</pre>

<pre>
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;rdf:RDF
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        xmlns:dclite4g="http://dclite4g.xmlns.com/schema.rdf#"&gt;
&lt;dclite4g:DataSet rdf:about="http://www.example.com/series/example_series/example_data_set/"&gt;
&lt;dc:subject rdf:resource="http://www.eionet.europa.eu/gemet/concept/8198" /&gt;   
&lt;dc:subject&gt;building&lt;/dc:subject&gt;
&lt;/dclite4g:DataSet&gt;
&lt;/rdf:RDF&gt;

</pre>
</p>
<a name="trans"/>
<h4>Transformation</h4>

<p>See the separate documentation for <a href="transformation.html">transforming different formats into RDF</a>. Support exists for a number of commonly-used XML-based formats for geographic metadata.</p>

<a name="ows"/>
<h3>OWS Import</h3>
<p>To import data from the GetCapabilities result of a <em>WMS</em> service, POST a section of RDF/XML referencing the server.
<pre>
        <b>/duetopia/register/dataset/import/wms</b>
</pre>

The following simple RDF snippet tells the server about a WMS resource:
<pre>
&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns="http://dclite4g.xmlns.com/ows.rdf#"&gt;

&lt;WMS rdf:about="http://labs.metacarta.com/wms/vmap0"&gt;
&lt;version&gt;1.1.1&lt;/version&gt;
&lt;/WMS&gt;
&lt;/rdf:RDF&gt;
</pre>

Currently there is only support for metadata collection from WMS; however the underlying <a href="http://trac.gispython.org/lab/wiki/OwsLib">owslib</a> library also supports WFS. How much work it would be to add WCS support is not ascertained.
</p>
<a name="opensearch"/>
<h3>OpenSearch</h3>

<p>See the <a href="opensearch.html">Opensearch documentation</a> for details on how to query the repository via an OpenSearch interface with Geo extensions, and how to add an OpenSearch interface to custom data products.</p>
<p>A simple <a href="opensearch_client.html">Opensearch client</a> written in 
get data for url - appending featureID to the base for the opensearch query. The result lists also have links to this detail view.

</p>

<div id="footer"/>
</div>

</body></html>
